Learn R Programming

bnlearn (version 3.1)

node ordering utilities: Utilities dealing with partial node orderings

Description

Find the partial node ordering implied by a network or generate the blacklist implied by a complete node ordering.

Usage

node.ordering(x, debug = FALSE)
ordering2blacklist(nodes)
tiers2blacklist(nodes)

Arguments

x
an object of class bn or bn.fit.
nodes
a node ordering, see below.
debug
a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.

Value

  • node.ordering return a vector of character strings, an ordered set of node labels.

    ordering2blacklist returns a sanitized blacklist (a two-column matrix, whose columns are labeled from and to).

Details

ordering2blacklist takes a vector of character strings (the labels of the nodes), which specifies a complete node ordering. An object of class bn or bn.fit; in that case, the node ordering is derived by the graph. In both cases, the blacklist returned by ordering2blacklist contains all the possible arcs that violate the specified node ordering.

tiers2blacklist takes (again) a vector of character strings (the labels of the nodes), which specifies a complete node ordering, or a list of character vectors, which specifies a partial node ordering. In the latter case, all arcs going from a node in a particular element of the list (sometimes known as tier) to a node in one of the previous elements are blacklisted. Arcs between nodes in the same element are not blacklisted.

Examples

Run this code
data(learning.test)
res = gs(learning.test, optimized = TRUE)
res$learning$ntests
# [1] 43
res = set.arc(res, "A", "B")
ord = node.ordering(res)
ord
# [1] "A" "C" "F" "B" "D" "E"

## partial node ordering saves us two tests in the v-structure
## detection step of the algorithm.
gs(learning.test, blacklist = ordering2blacklist(ord))$learning$ntests
# [1] 41

tiers2blacklist(list(LETTERS[1:3], LETTERS[4:6]))
#       from to 
#  [1,] "D"  "A"
#  [2,] "E"  "A"
#  [3,] "F"  "A"
#  [4,] "D"  "B"
#  [5,] "E"  "B"
#  [6,] "F"  "B"
#  [7,] "D"  "C"
#  [8,] "E"  "C"
#  [9,] "F"  "C"

Run the code above in your browser using DataLab